package com.gxc.socket;

import java.io.IOException;
import java.net.Socket;
import java.util.Scanner;

/**
 * @author 宫新程
 * @since 2018/12/18 11:13 PM
 */
public class SocketTest {

  public static void main(String[] args) throws IOException {

    try {
      Socket s = new Socket("www.baidu.com", 80);
      Scanner in = new Scanner(s.getInputStream(), "UTF-8");
      while (in.hasNextLine()) {
        String line = in.nextLine();
        System.out.println(line);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
